package com.jm.weibo.ui;


import weibo4andriod.Weibo;

import com.jm.weibo.db.SaveUserLoginParam;
import com.jm.weibo.logic.MainService;
import com.jm.weibo.util.NetUtil;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.Toast;

public class LogoActivity extends Activity {
    /** Called when the activity is first created. */
     
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 去掉Activity标题栏
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //去掉任务条
        this.getWindow().setFlags(
        		WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        		WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.logo);
        
        //定义splash   动画 
        AlphaAnimation aa=new AlphaAnimation(0.1f,1.0f);
        aa.setDuration(3000);
        this.findViewById(R.id.ImageView01).startAnimation(aa);
        aa.setAnimationListener(new AnimationListener(){

			 
			public void onAnimationEnd(Animation arg0) {
//				//自动登录
//				String param[]=SaveUserLoginParam.getUserLoginParam(LogoActivity.this);
//				if(param[0] !=null && param[0].length() != 0){
//					Toast.makeText(LogoActivity.this, "自动登录", Toast.LENGTH_SHORT).show();
//					if (NetUtil.checkNet(LogoActivity.this)) {// 联网正常  启动服务
//						if (!MainService.isrun) {
//							System.out.println("-------启动MainService服务--------");
//							MainService.isrun = true;
//							Intent it = new Intent(LogoActivity.this, MainService.class);
//							LogoActivity.this.startService(it);
//							
//						}
//						if(MainService.mainService == null){
//							System.out.println("-------MainService.mainService竟然是空的---------");
//							//MainService.mainService = new MainService();
//						}
//						MainService.mainService.weibo = new Weibo();
//						MainService.mainService.weibo.setUserId(param[0]);
//						MainService.mainService.weibo.setPassword(param[1]);
//						
//						
//						Intent it = new Intent(LogoActivity.this, HomeActivity.class);
//						LogoActivity.this.startActivity(it);
//						finish();
//				     }
//			    }else{
			    	Intent intent=new Intent(LogoActivity.this,LoginActivity.class);
					LogoActivity.this.startActivity(intent);
					finish();
//			    }
			}
			 
			public void onAnimationRepeat(Animation arg0) {
				// TODO Auto-generated method stub
				
			}

			 
			public void onAnimationStart(Animation arg0) {
				// TODO Auto-generated method stub
				
			}
        	
        }
        );
    }
}